//
//  OptionCell.swift
//  HealthMonitoring
//
//  Created by YTYanK on 2018/7/19.
//  Copyright © 2018年 YTYanK. All rights reserved.
//

import UIKit
import SwiftyJSON

class OptionCell: HMTableViewCell {
    
      var isShowArrow: Bool = false
      let icon = UIImageView()
      let title = UILabel()
      let describe = UILabel()
      let img = UIImageView()
    
    override func setupViews(view: UIView) {
        view.addSubview(icon)
        view.addSubview(title)
        view.addSubview(describe)
        view.addSubview(img)
        
        icon.imgName(name: "pl")
        icon.centerYAlign(view: view)
        icon.leadingAlign(view: view, predicate: "20")
        icon.widthConstrain(predicate: "35")
        icon.heightConstrain(predicate: "35")
        icon.contentMode = UIViewContentMode.scaleAspectFit
 
        title.leadingHorizontally(view: icon, predicate: "10")
        title.centerYAlign(view: view)
        title.text = ""
 
        

    
       describe.leadingHorizontally(view: title)
       describe.centerYAlign(view: view)
       describe.text = ""
       describe.textAlignment = NSTextAlignment.center
       describe.width(view: view, predicate: "*0.3")
            
            
        img.imgName(name: "xianjiang")
        img.centerYAlign(view: view, predicate: "4")
        img.leadingHorizontally(view: describe)
        img.widthConstrain(predicate: "20")
        img.heightConstrain(predicate: "20")
        img.trailingAlign(view: view, predicate: "-20")
        
        
        
    }
    
    override func setJson(json: JSON) {
        self.icon.imgName(name: json["icon"].stringValue)
        self.title.text = json["title"].stringValue
//        if json["describe"].stringValue
        self.describe.text = json["describe"].stringValue //!= nil ? json["describe"].stringValue : ""
        if json["describe"].stringValue == "" {
            self.img.isHidden = true
        }else {
            self.img.isHidden = false
        }
          //self.isShowArrow
    }
}
